package com.farm2.lucene.query;

import com.farm2.lucene.query.rule.DocumentRuleByVector;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class DocumentQuery {
    private int pageSize = 20;//查询总页数
    private int page = 1;//当前查询页
    private int allSize = 1000;//从索引中取回数据总数
    private boolean isHighlight = true;
    private List<DocumentRule> rules = new ArrayList<>();
    private DocumentSort sort;

    public DocumentQuery setHighlight(boolean isHighLight) {
        this.isHighlight = isHighLight;
        return this;
    }
    public void setAllSize(int allSize) {
        this.allSize = allSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }


    public void setPage(int page) {
        this.page = page;
    }


    public DocumentQuery addRule(DocumentRule rule) {
        if (rule instanceof DocumentRuleByVector) {
            //向量查询不做高亮
            this.setHighlight(false);
        }
        this.rules.add(rule);
        return this;
    }


    public DocumentQuery setSort(DocumentSort sort) {
        this.sort = sort;
        return this;
    }
}
